# author：黎先平

from Utilities.AutoGetOperator.selectPackage import get_func

Operator_IVQ_ROFS=get_func(r'Operators/OperationOperators/OperatorIVQROF.py','Operator_IVQ_ROFS')


class HamacherHMWA(Operator_IVQ_ROFS):

    def getResult(self):

        self.fi = self.x
        self.x = self.a
        self.y = self.b
        self.n = len(self.data_list)
        a1 = 0
        tempA11 = 1
        tempA12 = 1
        a2 = 0
        tempA21 = 1
        tempA22 = 1
        b1 = 0
        tempB11 = 1
        tempB12 = 1
        b2 = 0
        tempB21 = 1
        tempB22 = 1
        c1 = 0
        tempC11 = 1
        tempC12 = 1
        c2 = 0
        tempC21 = 1
        tempC22 = 1
        d1 = 0
        tempD11 = 1
        tempD12 = 1
        d2 = 0
        tempD21 = 1
        tempD22 = 1
        for i in range(self.n):
            for t in range(self.n):
                if i != t:
                    tempA11*=((getV(self.data_list[i][0][0],self.data_list[t][0][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)+(self.fi**2-1)*getW(self.data_list[i][0][0],self.data_list[t][0][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempA12*=((getV(self.data_list[i][0][0],self.data_list[t][0][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)-getW(self.data_list[i][0][0],self.data_list[t][0][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempA21*=((getV(self.data_list[i][0][1],self.data_list[t][0][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)+(self.fi**2-1)*getW(self.data_list[i][0][1],self.data_list[t][0][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempA22*=((getV(self.data_list[i][0][1],self.data_list[t][0][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)-getW(self.data_list[i][0][1],self.data_list[t][0][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempB11*=((getV(self.data_list[i][0][0],self.data_list[t][0][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)+(self.fi**2-1)*getW(self.data_list[i][0][0],self.data_list[t][0][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempB12*=((getV(self.data_list[i][0][0],self.data_list[t][0][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)-getW(self.data_list[i][0][0],self.data_list[t][0][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempB21*=((getV(self.data_list[i][0][1],self.data_list[t][0][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)+(self.fi**2-1)*getW(self.data_list[i][0][1],self.data_list[t][0][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempB22*=((getV(self.data_list[i][0][1],self.data_list[t][0][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)-getW(self.data_list[i][0][1],self.data_list[t][0][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempC11*=((getN(self.data_list[i][1][0],self.data_list[t][1][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)+((self.fi**2)-1)*getM(self.data_list[i][1][0],self.data_list[t][1][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempC12*=((getN(self.data_list[i][1][0],self.data_list[t][1][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)-getM(self.data_list[i][1][0],self.data_list[t][1][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempC21*=((getN(self.data_list[i][1][1],self.data_list[t][1][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)+((self.fi**2)-1)*getM(self.data_list[i][1][1],self.data_list[t][1][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempC22*=((getN(self.data_list[i][1][1],self.data_list[t][1][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)-getM(self.data_list[i][1][1],self.data_list[t][1][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempD11*=(((getN(self.data_list[i][1][0],self.data_list[t][1][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)+(self.fi**2)-1)*getM(self.data_list[i][1][0],self.data_list[t][1][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempD12*=((getN(self.data_list[i][1][0],self.data_list[t][1][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)-getM(self.data_list[i][1][0],self.data_list[t][1][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempD21*=((getN(self.data_list[i][1][1],self.data_list[t][1][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)+((self.fi**2)-1)*getM(self.data_list[i][1][1],self.data_list[t][1][0],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
                    tempD22*=((getN(self.data_list[i][1][1],self.data_list[t][1][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q)-getM(self.data_list[i][1][1],self.data_list[t][1][1],self.fi,self.x,self.y,self.weight_list[i],self.weight_list[t],self.q))**2)**(1/(self.n*(self.n+1)))
        a1 = (tempA11+(self.fi**2-1)*tempA12)**(1/(2*(self.x+self.y)))
        a2 = (tempA21+(self.fi**2-1)*tempA22)**(1/(2*(self.x+self.y)))
        b1 = (tempB11-tempB12)**(1/(2*(self.x+self.y)))
        b2 = (tempB21-tempB22)**(1/(2*(self.x+self.y)))
        c1 = (tempC11-tempC12)**(1/(2*(self.x+self.y)))
        c2 = (tempC21-tempC22)**(1/(2*(self.x+self.y)))
        d1 = ((tempD11+((self.fi**2)-1)*tempD12))**(1/(2*(self.x+self.y)))+(self.fi-1)*((tempD11+tempD12)**(1/(2*(self.x+self.y))))
        d2 = ((tempD21+((self.fi**2)-1)*tempD22))**(1/(2*(self.x+self.y)))+(self.fi-1)*((tempD21+tempD22)**(1/(2*(self.x+self.y))))

        e1=(d1-c1)
        e2=(d2-c2)
        a = ((a1-b1)/(a1+(self.fi-1)*b1))**(1/self.q)
        b = ((a2-b2)/(a2+(self.fi-1)*b2))**(1/self.q)
        c = (self.fi*(e1)/((c1+((self.fi**2)-1)*d1)+(self.fi-1)*(e1)))**(1/(self.q))
        d = (self.fi*(e2)/((c2+((self.fi**2)-1)*d2)+(self.fi-1)*(e2)))**(1/(self.q))
        result =([(a,b),(c,d)])
        return result

def getV(ui,uj,fi,x,y,wi,wj,q):
    return ((((1+(fi-1)*(1-(ui)**q))**wi)+((fi**2)-1)*((ui)**q)**wi)**x)*((((1+(fi-1)*(1-(uj)**q))**wj)+(fi**2-1)*(((uj)**q)**wj))**y)
def getW(ui,uj,fi,x,y,wi,wj,q):
    return ((((1+(fi-1)*(1-(ui)**q))**wi)-((ui)**q)**wi)**x)*((((1+(fi-1)*(1-(uj)**q))**wj)-((uj)**q)**wj)**y)
def getN(vi,vj,fi,x,y,wi,wj,q):
    return ((((1+(fi-1)*(1-(vi)**q))**wi)+(((fi**2)-1)*((1-(vi)**q)**wi)))**x)*((((1+(fi-1)*(vj**q))**wj)+((fi**2)-1)*((1-vj**q)**wj))**y)
def getM(vi,vj,fi,x,y,wi,wj,q):
    return ((((1+(fi-1)*(vi**q))**wi)-(1-(vi**q))**wi)**x)*((((1+(fi-1)*(vj**q))**wj)-(1-(vj**q))**wj)**y)
